hyper = {"command","option"}
-- 当前窗口 2分屏 宽度1/2 左分屏
hs.hotkey.bind(hyper, "Left", function()
  local win = hs.window.focusedWindow()
    local f = win:frame()
    local screen = win:screen()
    local max = screen:frame()

    f.x = max.x
    f.y = max.y
    f.w = max.w / 2
    f.h = max.h
    win:setFrame(f)
end)

-- 当前窗口 2分屏 宽度1/2 右分屏
hs.hotkey.bind(hyper, "Right", function()
  local win = hs.window.focusedWindow()
    local f = win:frame()
    local screen = win:screen()
    local max = screen:frame()

    f.x = max.x + max.w/2
    f.y = max.y
    f.w = max.w / 2
    f.h = max.h
    win:setFrame(f)
end)

-- 当前窗口 2分屏 宽度1/2 上分屏
hs.hotkey.bind(hyper, "Up", function()
  local win = hs.window.focusedWindow()
    local f = win:frame()
    local screen = win:screen()
    local max = screen:frame()

    f.x = max.x
    f.y = max.y
    f.w = max.w
    f.h = max.h*0.5
    win:setFrame(f)
end)

-- 当前窗口 2分屏 宽度1/2 下分屏
hs.hotkey.bind(hyper, "Down", function()
  local win = hs.window.focusedWindow()
    local f = win:frame()
    local screen = win:screen()
    local max = screen:frame()

    f.x = max.x
    f.y = max.y + max.h/2
    f.w = max.w
    f.h = max.h / 2
    win:setFrame(f)
end)

-- 当前窗口 全屏
hs.hotkey.bind(hyper, "return", function()
  local win = hs.window.focusedWindow()
    local f = win:frame()
    local screen = win:screen()
    local max = screen:frame()

    f.x = max.x
    f.y = max.y
    f.w = max.w
    f.h = max.h
    win:setFrame(f)
end)

-- -- 当前窗口 向左移动，收缩一半
-- hs.hotkey.bind({"option","shift"}, "left", function()
--   local win = hs.window.focusedWindow()
--     local f = win:frame()
--     local screen = win:screen()
--     local max = screen:frame()

--     f.x = max.x
--     f.y = f.y
--     f.w = max.w/2
--     f.h = f.h
--     win:setFrame(f)
-- end)

-- -- 当前窗口 向右移动，收缩一半
-- hs.hotkey.bind({"option","shift"}, "right", function()
--   local win = hs.window.focusedWindow()
--     local f = win:frame()
--     local screen = win:screen()
--     local max = screen:frame()

--     f.x = max.x + max.w/2
--     f.y = f.y
--     f.w = max.w/2
--     f.h = f.h
--     win:setFrame(f)
-- end)

-- -- 当前窗口 向上移动，收缩一半
-- hs.hotkey.bind({"option","shift"}, "up", function()
--   local win = hs.window.focusedWindow()
--     local f = win:frame()
--     local screen = win:screen()
--     local max = screen:frame()

--     f.x = f.x
--     f.y = max.y
--     f.w = f.w
--     f.h = max.h/2
--     win:setFrame(f)
-- end)

-- -- 当前窗口 向右移动，收缩一半
-- hs.hotkey.bind({"option","shift"}, "down", function()
--   local win = hs.window.focusedWindow()
--     local f = win:frame()
--     local screen = win:screen()
--     local max = screen:frame()

--     f.x = f.x
--     f.y = max.y + max.h/2
--     f.w = f.w
--     f.h = max.h/2
--     win:setFrame(f)
-- end)